package indi.flynn.zhouyi.thread;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController()
@RequestMapping("/thread")
@Slf4j
public class ThreadController {

    @Autowired
    private TaskRunner taskRunner;

    @GetMapping("/msg")
    public String msg() {
        log.info("enter msg");

        // 使用实现 Runnable 的 Spring Bean 创建线程
        Thread thread = new Thread(taskRunner);
        thread.start();

        return "ok";
    }
}
